import { ContentType } from '@/enums/httpEnum';
import { request } from '@umijs/max';

// 查询资产信息列表
export async function getAssetList(params?: API.Manage.AssetListParams) {
  return request<API.Manage.AssetPageResult>('/api/inspection/asset/list', {
    method: 'GET',
    headers: { 'Content-Type': ContentType.FORM_URLENCODED },
    params
  });
}


//新增资产
export function addAsset(params: API.Manage.Asset) {
  return request<API.Result>('/api/inspection/asset/add', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json;charset=UTF-8',
    },
    data: params,
  });
}

//更新资产
export function updateAsset(params: API.Manage.Asset) {
    return request<API.Result>('/api/inspection/asset/update', {
      method: 'POST',
      headers: {
          'Content-Type': 'application/json;charset=UTF-8',
      },
      data: params,
    });
  }

// 删除资产信息
export async function removeAsset(ids: number[]) {
  return request<API.Result>('/api/inspection/asset/deletes', {
    method: 'POST',
    data: ids
  });
}

// 获取所有设备名称
export async function getdeviceNames() {
  return request<API.Manage.ListResult>('/api/inspection/asset/allDeviceName', {
    method: 'GET'
  });
}

// 获取所有在线设备名称
export async function getOnlineDeviceNames() {
  return request<API.Manage.ListResult>('/api/inspection/asset/allOnlineDeviceName', {
    method: 'GET'
  });
}

//获取所有设备类型
export async function getdeviceTypes() {
  return request<API.Manage.ListResult>('/api/inspection/deviceType/typeNames', {
    method: 'GET'
  });
}

//根据设备名称查看下面的设备编号
export async function getDeviceNumsByName(deviceName: string) {
  return request<API.Manage.ListResult>(`/api/inspection/asset/deviceNums?deviceName=${deviceName}`, {
    method: 'GET',
    data : deviceName
  });
}

//根据设备编号查看下面的设备IP地址
export async function getDeviceIpByNum(deviceNum: string) { 
  return request<API.Manage.ListResult>(`/api/inspection/asset/deviceIP?deviceNum=${deviceNum}`, {
    method: 'GET',
    data : deviceNum
  });
}